﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace COP.Objects.Maps
{
    public delegate void MapProcessEventHandler(MAPBase map);
    public abstract class MAPBase
    {
        protected string key = null;
        public string Key
        {
            get { return key; }
            set
            {
                this.
                    key = value;
            }
        }

        protected object value = null;
        public object Value
        {
            get { return this.value; }
            set { this.value = value; }
        }

        protected string method = null;
        public string Method
        {
            get { return method; }
        }


        public List<MAPBase> otherKeys = null;

        public List<MAPBase> OtherKeys
        {
            get { return otherKeys; }
            internal set { otherKeys = value; }
        }

        public event MapProcessEventHandler MapProcess = null;
        protected void OnMapProcess()
        {
            if (this.MapProcess != null)
                MapProcess(this);
        }

        public abstract void Append(object data);

        public virtual void AppendDelegate(object caller)
        {
            if (!string.IsNullOrEmpty(this.method))
                this.MapProcess += (MapProcessEventHandler)Delegate.CreateDelegate(typeof(MapProcessEventHandler), caller, this.method);

        }

        public abstract object Process();

        public MAPBase Clone()
        {
            return (MAPBase)this.MemberwiseClone();
        }

    }
}
